{{header}}{{column_left}}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-category" data-toggle="tooltip" title="{{button_save}}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{cancel}}" data-toggle="tooltip" title="{{button_cancel}}" class="btn btn-default"><i class="fa fa-reply"></i></a></div>
      <h1>{{heading_title}}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{breadcrumb.href}}">{{breadcrumb.text}}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{error_warning}}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{text_form}}</h3>
      </div>
      <div class="panel-body">
        <form action="{{action}}" method="post" enctype="multipart/form-data" id="form-category" class="form-horizontal">
          <ul class="nav nav-tabs">
            <li class="active"><a href="#tab-general" data-toggle="tab">{{tab_general}}</a></li>
            <li><a href="#tab-data" data-toggle="tab">{{tab_data}}</a></li>
            <li><a href="#tab-setting" data-toggle="tab">{{tab_setting}}</a></li>
            <li><a href="#tab-links" data-toggle="tab">{{tab_links}}</a></li>
            <li><a href="#tab-design" data-toggle="tab">{{tab_design}}</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active in" id="tab-general">
              <ul class="nav nav-tabs" id="language">
                {% for language in languages %}
                <li><a href="#language{{language.language_id}}" data-toggle="tab"><img src="{{language.flag}}" title="{{language.name}}" /> {{language.name}}</a></li>
                {% endfor %}
              </ul>
              <div class="tab-content">
                {% for language in languages %}
                <div class="tab-pane" id="language{{language.language_id}}">
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-name{{language.language_id}}">{{entry_title}}</label>
                    <div class="col-sm-10">
                      <input type="text" name="category_description[{{language.language_id}}][title]" value="{{ category_description[language.language_id] ? category_description[language.language_id].title : '' }}" placeholder="{{entry_title}}" id="input-name{{language.language_id}}" class="form-control" />
                      {% if error_name[language.language_id] %}
                      <div class="text-danger">{{error_name[language.language_id]}}</div>
                      {% endif %}
                    </div>
                  </div>
				  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-short-description{{language.language_id}}">{{entry_short_description}}</label>
                    <div class="col-sm-10">
                        <textarea name="category_description[{{language.language_id}}][short_description]" placeholder="{{entry_short_description}}" class="form-control" id="input-short-description{{language.language_id}}">{{ category_description[language.language_id] ? category_description[language.language_id].short_description : ''}}</textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-description{{language.language_id}}">{{entry_description}}</label>
                    <div class="col-sm-10">
                      <textarea name="category_description[{{language.language_id}}][description]" placeholder="{{entry_description}}" class="d_visual_designer form-control summernote" id="input-description{{language.language_id}}" data-toggle="summernote" >{{category_description[language.language_id] ? category_description[language.language_id].description : ''}}</textarea>
                    </div>
                  </div>
                  <div class="form-group required">
                    <label class="col-sm-2 control-label" for="input-meta-title{{language.language_id}}">{{entry_meta_title}}</label>
                    <div class="col-sm-10">
                      <input type="text" name="category_description[{{language.language_id}}][meta_title]" value="{{category_description[language.language_id] ? category_description[language.language_id].meta_title : ''}}" placeholder="{{entry_meta_title}}" id="input-meta-title{{language.language_id}}" class="form-control" />
                      {% if error_meta_title[language.language_id] %}
                      <div class="text-danger">{{error_meta_title[language.language_id]}}</div>
                      {% endif %}
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-meta-description{{language.language_id}}">{{entry_meta_description}}</label>
                    <div class="col-sm-10">
                      <textarea name="category_description[{{language.language_id}}][meta_description]" rows="5" placeholder="{{entry_meta_description}}" id="input-meta-description{{language.language_id}}" class="form-control">{{category_description[language.language_id] ? category_description[language.language_id].meta_description : ''}}</textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-2 control-label" for="input-meta-keyword{{language.language_id}}">{{entry_meta_keyword}}</label>
                    <div class="col-sm-10">
                      <textarea name="category_description[{{language.language_id}}][meta_keyword]" rows="5" placeholder="{{entry_meta_keyword}}" id="input-meta-keyword{{language.language_id}}" class="form-control">{{category_description[language.language_id] ? category_description[language.language_id].meta_keyword : ''}}</textarea>
                    </div>
                  </div>
                </div>
                {% endfor %}
              </div>
            </div>
            <div class="tab-pane fade" id="tab-data">
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-parent">{{entry_parent}}</label>
                <div class="col-sm-10">
                  <input type="text" name="path" value="{{path}}" placeholder="{{entry_parent}}" id="input-parent" class="form-control" />
                  <input type="hidden" name="parent_id" value="{{parent_id}}" />
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label">{{entry_store}}</label>
                <div class="col-sm-10">
                  <div class="well well-sm" style="height: 150px; overflow: auto;">
                    <div class="checkbox">
                      <label>
                        {% if 0 in category_store %}
                        <input type="checkbox" name="category_store[]" value="0" checked="checked" />
                        {{text_default}}
                        {% else %}
                        <input type="checkbox" name="category_store[]" value="0" />
                        {{text_default}}
                        {% endif %}
                      </label>
                    </div>
                    {% for store in stores %}
                    <div class="checkbox">
                      <label>
                        {% if store.store_id in category_store %}
                        <input type="checkbox" name="category_store[]" value="{{store.store_id}}" checked="checked" />
                        {{store.name}}
                        {% else %}
                        <input type="checkbox" name="category_store[]" value="{{store.store_id}}" />
                        {{store.name}}
                        {% endif %}
                      </label>
                    </div>
                    {% endfor %}
                  </div>
                </div>
              </div>
              
              <div class="form-group">
                <label class="col-sm-2 control-label">{{entry_image}}</label>
                <div class="col-sm-10"><a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="{{thumb}}" alt="" title="" data-placeholder="{{placeholder}}" /></a>
                  <input type="hidden" name="image" value="{{image}}" id="input-image" />
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-sort-order">{{entry_sort_order}}</label>
                <div class="col-sm-10">
                  <input type="text" name="sort_order" value="{{sort_order}}" placeholder="{{entry_sort_order}}" id="input-sort-order" class="form-control" />
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-status">{{entry_status}}</label>
                <div class="col-sm-10">
                  <select name="status" id="input-status" class="form-control">
                    {% if status %}
                    <option value="1" selected="selected">{{text_enabled}}</option>
                    <option value="0">{{text_disabled}}</option>
                    {% else %}
                    <option value="1">{{text_enabled}}</option>
                    <option value="0" selected="selected">{{text_disabled}}</option>
                    {% endif %}
                  </select>
                </div>
              </div>
            </div>
            <div class="tab-pane" id="tab-setting">
                <div class="tab-body">

                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="input_category_custom">{{entry_category_custom}}</label>
                        <div class="col-sm-10">
                            <input type="hidden" name="custom" value="0" />
                            <input type="checkbox" class="switcher" data-label-text="{{text_enabled}}" id="input_category_custom" name="custom" {{ custom ? 'checked="checked"' : '' }} value="1" />
                        </div>
                    </div><!-- //checkbox -->
                    <div id="input_category_custom_form" {{ custom ? '' : 'class="hide"' }} >
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_category_layout_type">{{entry_category_layout_type}}</label>
                            <div class="col-sm-10">
                                <div class="btn-group colors" data-toggle="buttons">
                                    {% for layout_type in layout_types %}
                                    <label class="btn btn-default {% if setting.layout_type and layout_type.id == setting.layout_type %}active{% endif %}"
                                     data-toggle="tooltip" data-html="true" title="{{layout_type.description|e('html')}}">
                                        <input type="radio" name="setting[layout_type]" value="{{layout_type.id}}" autocomplete="off" {% if setting.layout_type and layout_type.id == setting.layout_type %}checked{% endif %}> {{layout_type.name}}
                                    </label>
                                    {% endfor %}
                                </div>
                            </div>
                        </div><!-- //status -->



                        <div class="form-group" id="category_layout">
                            <label class="col-sm-2 control-label" for="input_category_layout">{{entry_category_layout}}</label>
                            <div class="col-sm-10 ">
                                <div class="input">

                                {% for layout in setting.layout %}

                                <div class="input-group m-b">
                                    <select name="setting[layout][]"  class="form-control">
                                        {% for col in cols %}
                                        <option value="{{col}}" {% if layout == col %} selected="selected" {% endif %}>{{col}}</option>
                                        {% endfor %}
                                    </select>
                                    <span class="input-group-btn">
                                        <button class="btn btn-default remove" >{{button_remove}}</button>
                                    </span>
                                </div><!-- /input-group -->

                                {% endfor %}
                                </div>
                                <button class="btn btn-default add m-b">{{button_add}}</button>
                                <div class="bs-callout bs-callout-warning">
                                    {{help_layout}}
                                </div>
                            </div>
                            <script type="text" id="template_input_category_layout">
                                <div class="input-group m-b">
                                        <select name="setting[layout][]" class="form-control">
                                            {% for col in cols %}
                                               <option value="{{col}}">{{col}}</option>
                                            {% endfor %}
                                        </select>

                                      <span class="input-group-btn">
                                        <button class="btn btn-default remove" >{{button_remove}}</button>
                                      </span>
                                </div>
                            </script>
                            <script>
                            var $category_layout = $('#category_layout');
                            $(document).on('click', '#category_layout .add', function(e){

                                var html = $('#template_input_category_layout').html();
                                $category_layout.find('.input').append(html);
                                e.preventDefault();
                            })
                            $(document).on('click', '#category_layout .remove', function(e){
                                $(this).parents('.input-group').remove()
                                e.preventDefault();
                            })

                            </script>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_text">{{entry_category_post_page_limit}}</label>
                            <div class="col-sm-10">
                                <input type="text" name="setting[post_page_limit]" value="{{setting.post_page_limit}}" placeholder="{{entry_category_post_page_limit}}"  class="form-control" />
                            </div>
                        </div><!-- //post_page_limit -->
                        
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_checkbox">{{entry_category_image_display}}</label>
                            <div class="col-sm-10">
                                <input type="hidden" name="setting[image_display]" value="0" />
                                <input type="checkbox" class="switcher" data-label-text="{{text_enabled}}" id="input_category_image_display" name="setting[image_display]" {{ setting.image_display ? 'checked="checked"' : '' }} value="1" />
                            </div>
                        </div><!-- //checkbox -->

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_text">{{entry_category_image_size}}</label>
                            <div class="col-sm-5">
                                <div class="input-group">
                                    <span class="input-group-addon">{{text_width}}</span>
                                    <input type="text" name="setting[image_width]" value="{{setting.image_width}}" placeholder="{{text_width}}"  class="form-control" />
                                </div>


                            </div>
                            <div class="col-sm-5">
                                <div class="input-group">
                                    <span class="input-group-addon">{{text_height}}</span>
                                    <input type="text" name="setting[image_height]" value="{{setting.image_height}}" placeholder="{{text_height}}"  class="form-control" />
                                </div>
                            </div>
                        </div><!-- //category_image -->

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_checkbox">{{entry_category_sub_category_display}}</label>
                            <div class="col-sm-10">
                                <input type="hidden" name="setting[sub_category_display]" value="0" />
                                <input type="checkbox" class="switcher" data-label-text="{{text_enabled}}" id="input_category_sub_category_display" name="setting[sub_category_display]" {{ setting.sub_category_display ? 'checked="checked"' : '' }} value="1" />
                            </div>
                        </div><!-- //checkbox -->


                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_select">{{entry_category_sub_category_col}}</label>
                            <div class="col-sm-10">
                                <select name="setting[sub_category_col]" id="input_category_sub_category_col" class="form-control">
                                    {% for col in cols %}
                                    <option value="{{col}}" {% if setting.sub_category_col == col %} selected="selected" {% endif %}>{{col}}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div><!-- //select -->

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_checkbox">{{entry_category_sub_category_image}}</label>
                            <div class="col-sm-10">
                                <input type="hidden" name="setting[sub_category_image]" value="0" />
                                <input type="checkbox" class="switcher" data-label-text="{{text_enabled}}"id="input_category_sub_category_image" name="setting[sub_category_image]" {{ setting.sub_category_image ? 'checked="checked"' : '' }} value="1" />
                            </div>
                        </div><!-- //checkbox -->

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_checkbox">{{entry_category_sub_category_post_count}}</label>
                            <div class="col-sm-10">
                                <input type="hidden" name="setting[sub_category_post_count]" value="0" />
                                <input type="checkbox" class="switcher" data-label-text="{{text_enabled}}" id="input_category_sub_category_post_count" name="setting[sub_category_post_count]" {{ setting.sub_category_post_count ? 'checked="checked"' : '' }} value="1" />
                            </div>
                        </div><!-- //checkbox -->

                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="input_text">{{entry_category_sub_category_image_size}}</label>
                            <div class="col-sm-5">
                                <div class="input-group">
                                    <span class="input-group-addon">{{text_width}}</span>
                                    <input type="text" name="setting[sub_category_image_width]" value="{{setting.sub_category_image_width}}" placeholder="{{text_width}}" class="form-control" />
                                </div>


                            </div>
                            <div class="col-sm-5">
                                <div class="input-group">
                                    <span class="input-group-addon">{{text_height}}</span>
                                    <input type="text" name="setting[sub_category_image_height]" value="{{setting.sub_category_image_height}}" placeholder="{{text_height}}"  class="form-control" />
                                </div>
                            </div>
                        </div><!-- //category_image -->
                    </div>
                </div>
            </div>

            <div class="tab-pane" id="tab-links">
              <script type="application/javascript">
                  $(document).ready(function() {
                      $(".switcher[type='checkbox']").bootstrapSwitch({
                          'onColor': 'success',
                          'onText': '{{ text_yes }}',
                          'offText': '{{ text_no }}',
                      });
                      $('input[type=checkbox][name$="limit_access_user"]').on('switchChange.bootstrapSwitch', function (event, state) {
                          if (state) {
                              $('input[type=checkbox][name$="limit_access_user_group"]').bootstrapSwitch('state', false);
                              $('#users').show();
                          }
                          else {
                              $('#users').hide();
                          }
                      });
                      $('input[type=checkbox][name$="limit_access_user"]').trigger('switchChange.bootstrapSwitch', {{ limit_access_user }});
                      $('input[type=checkbox][name$="limit_access_user_group"]').on('switchChange.bootstrapSwitch', function (event, state) {
                          if (state) {
                              $('input[type=checkbox][name$="limit_access_user"]').bootstrapSwitch('state', false);
                              $('#user_groups').show();
                          }
                          else {
                              $('#user_groups').hide();
                          }
                      });
                      $('input[type=checkbox][name$="limit_access_user_group"]').trigger('switchChange.bootstrapSwitch', {{ limit_access_user_group }});
                      $('input[name="user"]').autocomplete({
                          'source': function (request, response) {
                              $.ajax({
                                  url: 'index.php?route=customer/customer/autocomplete&{{ url_token }}&filter_name=' + encodeURIComponent(request),
                                  dataType: 'json',
                                  success: function (json) {
                                      response($.map(json, function (item) {
                                          return {
                                              label: item['firstname'],
                                              value: item['customer_id']
                                          }
                                      }));
                                  }
                              });
                          },
                          'select': function (item) {
                              $('input[name=\'user\']').val('');

                              $('#access-user' + item['value']).remove();

                              $('#access-user').append('<div id="access-user' + item['value'] + '"><i class="fa fa-minus-circle"></i> ' + item['label'] + '<input type="hidden" name="access_user[]" value="' + item['value'] + '" /></div>');
                          }
                      });
                      $('#access-user').delegate('.fa-minus-circle', 'click', function () {
                          $(this).parent().remove();
                      });
                      $('input[name=\'user_group\']').autocomplete({
                          'source': function (request, response) {
                              $.ajax({
                                  url: 'index.php?route=extension/d_blog_module/post/autocompleteUserGroup&{{ url_token}}&filter_name=' + encodeURIComponent(request),
                                  dataType: 'json',
                                  success: function (json) {
                                      response($.map(json, function (item) {
                                          return {
                                              label: item['name'],
                                              value: item['customer_group_id']
                                          }
                                      }));
                                  }
                              });
                          },
                          'select': function (item) {
                              $('input[name=\'user_group\']').val('');

                              $('#access-user-group' + item['value']).remove();

                              $('#access-user-group').append('<div id="access-user-group' + item['value'] + '"><i class="fa fa-minus-circle"></i> ' + item['label'] + '<input type="hidden" name="access_user_group[]" value="' + item['value'] + '" /></div>');
                          }
                      });
                      $('#access-user-group').delegate('.fa-minus-circle', 'click', function () {
                          $(this).parent().remove();
                      });
                  });
              </script>              
              <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-limit-access-user">{{entry_limit_access_user}}</label>
                  <div class="col-sm-10">
                      <input type="hidden" name="limit_access_user" value="0" />
                      <input type="checkbox" name="limit_access_user" class="switcher" data-label-text="{{text_enabled}}" id="input-limit-access-user" {{ limit_access_user ? 'checked="checked"' }} value="1" />
                  </div>
              </div>
              <div class="form-group" id="users">
                  <label class="col-sm-2 control-label" for="input-user">{{entry_user}}</label>
                  <div class="col-sm-10">
                      <input type="text" name="user" value="" placeholder="{{entry_user}}" id="input-user" class="form-control" />
                      <div id="access-user" class="well well-sm" style="height: 150px; overflow: auto;">
                          {% for key, value in users %}
                              <div id="access-user{{key}}">
                                  <i class="fa fa-minus-circle"></i>
                                  {{value}}
                                  <input type="hidden" name="access_user[]" value="{{key}}" />
                              </div>
                          {% endfor %}
                      </div>
                  </div>
              </div>
              <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-limit-access-user-group">{{entry_limit_access_user_group}}</label>
                  <div class="col-sm-10">
                      <input type="hidden" name="limit_access_user_group" value="0" />
                      <input type="checkbox" name="limit_access_user_group" class="switcher" data-label-text="{{text_enabled}}" id="input-limit-access-user-group" {{ limit_access_user_group ? 'checked="checked"' }} value="1" />
                  </div>
              </div>
              <div class="form-group" id="user_groups">
                  <label class="col-sm-2 control-label" for="input-user-group">{{entry_user_group}}</label>
                  <div class="col-sm-10">
                      <input type="text" name="user_group" value="" placeholder="{{entry_user_group}}" id="input-user-group" class="form-control" />
                      <div id="access-user-group" class="well well-sm" style="height: 150px; overflow: auto;">
                          {% for key, value in user_groups %}
                              <div id="access-user-group{{key}}">
                                  <i class="fa fa-minus-circle"></i>
                                  {{value}}
                                  <input type="hidden" name="access_user_group[]" value="{{key}}" />
                              </div>
                          {% endfor %}
                      </div>
                  </div>
              </div>
          </div>
            <div class="tab-pane" id="tab-design">
              <div class="table-responsive">
                <table class="table table-bordered table-hover">
                  <thead>
                    <tr>
                      <td class="text-left">{{entry_store}}</td>
                      <td class="text-left">{{entry_layout}}</td>
                    </tr>
                  </thead>
                  <tbody>
                    <tr>
                      <td class="text-left">{{text_default}}</td>
                      <td class="text-left"><select name="category_layout[0]" class="form-control">
                          <option value=""></option>
                          {% for layout in layouts %}
                          {% if category_layout[0] and category_layout[0] == layout.layout_id %}
                          <option value="{{layout.layout_id}}" selected="selected">{{layout.name}}</option>
                          {% else %}
                          <option value="{{layout.layout_id}}">{{layout.name}}</option>
                          {% endif %}
                          {% endfor %}
                        </select></td>
                    </tr>
                    {% for store in stores %}
                    <tr>
                      <td class="text-left">{{store.name}}</td>
                      <td class="text-left"><select name="category_layout[{{store.store_id}}]" class="form-control">
                          <option value=""></option>
                          {% for layout in layouts %}
                          {% if category_layout[store.store_id] and category_layout[store.store_id] == layout.layout_id %}
                          <option value="{{layout.layout_id}}" selected="selected">{{layout.name}}</option>
                          {% else %}
                          <option value="{{layout.layout_id}}">{{layout.name}}</option>
                          {% endif %}
                          {% endfor %}
                        </select></td>
                    </tr>
                    {% endfor %}
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <script type="text/javascript"><!--
{% for language in languages %}
{% if not store_2302 %}
$('#input-description{{language.language_id}}').summernote({
	height: 300
});
{% endif %}
{% endfor %}

//checkbox
    $(".switcher[type='checkbox']").bootstrapSwitch({
        'onColor': 'success',
        'labelWidth': '50',
        'onText': '{{text_yes}}',
        'offText': '{{text_no}}',
    }).on('switchChange.bootstrapSwitch', function(event, state) {

        if($(this).attr('id') == 'input_category_custom'){
            if(state){
                $('#input_category_custom_form').removeClass('hide')
            }else{
                 $('#input_category_custom_form').addClass('hide')
            }
        }
    });

$('input[name=\'path\']').autocomplete({
	'source': function(request, response) {
		$.ajax({
			url: '{{category_autocomplete}}&filter_title=' +  encodeURIComponent(request),
			dataType: 'json',
			success: function(json) {
				json.unshift({
					category_id: 0,
					name: '{{text_none}}'
				});

				response($.map(json, function(item) {
					return {
						label: item['title'],
						value: item['category_id']
					}
				}));
			}
		});
	},
	'select': function(item) {
		$('input[name=\'path\']').val(item['label']);
		$('input[name=\'parent_id\']').val(item['value']);
	}
});
//--></script>

  <script type="text/javascript"><!--
$('#language a:first').tab('show');
//--></script></div>
{{footer}}
